var mysql = require('mysql');
var express = require('express');
/**
 * 配置MySql
 */
var connection;
function Connect() {
    connection = mysql.createConnection({
        host: '116.62.37.172',
        user: 'gy_m',
        password: '123456',
        database: 'gy_project',
        port: '3306',
        useConnectionPooling: true,
        multipleStatements: true
    });
    connection.connect(function (err) {
        if (err) {
            console.error('error connecting: ', err.stack);
            setTimeout(Connect, 1000);
            return;
        }
    });
    connection.on("error", function (err) {
        console.log("数据库已断开连接，大概是你的网络有问题。");
        Connect();
        console.log("Caught: " + err.code);
    });
}
Connect();
module.exports = connection;